<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="../../Templates/SubFolderTemplate.xhtml"
                xmlns:p="http://primefaces.prime.com.tr/ui"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:f="http://java.sun.com/jsf/core">
    
    <ui:define name="head-title">
        <title>Add Shipping Order From Packing Order | Merlion's ERP System</title>
    </ui:define>
    
    <ui:define name="content">
        <f:view beforePhase="#{addShippingOrderManagerBean.initView(event)}">
          <h:form>
            <p:panel id="panel" header="Add New Shipping Order"> 
                <p:ajaxStatus style="width:16px;height:16px;">   
                    <f:facet name="start">   
                        <p:graphicImage value="http://www.primefaces.org:8080/showcase/design/ajaxloading.gif" /> 
                    </f:facet> 
 
                    <f:facet name="complete">   
                        <h:outputText value="" />   
                    </f:facet>   
                </p:ajaxStatus> 
            
                <p:messages /> 
                
                <h:panelGrid columns="3" cellpadding="2"> 
                    <f:facet name="header">
                        <h:outputText value="Packing Order Information:"/>
                    </f:facet>
                    <h:outputLabel for="packingOrderId" style="font-weight: bold" value="Packing Order ID: " />
                    <h:outputText value="#{addShippingOrderManagerBean.selectedPackingOrder.id}"  id="packingOrderId"/>
                    <p:message for="packingOrderId" /> 
                    
                    <h:outputLabel for="packingOrderDate" style="font-weight: bold" value="Packing Order Date: " />
                    <h:outputText value="#{addShippingOrderManagerBean.selectedPackingOrder.packingDate}" id="packingOrderDate"/>
                    <p:message for="packingOrderDate" /> 
                    
                    <h:outputLabel for="deliveryOrderId" style="font-weight: bold" value="Delivery order ID: " />
                    <h:outputText value="#{addShippingOrderManagerBean.selectedPackingOrder.deliveryOrder.id}" id="deliveryOrderId"/> 
                    <p:message for="deliveryOrderId" /> 
                </h:panelGrid>
                
                <p:dataTable var="productLine" value="#{addShippingOrderManagerBean.selectedPackingOrder.deliveryOrder.pickingOrder.productLines}"
                             dynamic="true" paginator="true" emptyMessage="No Product Type" style="width: 50%;">
                    <p:column sortBy="#{productLine.product.productType}">
                        <f:facet name="header">
                            <h:outputText value="Product Type"/>
                        </f:facet>
                        <h:outputText value="#{productLine.product.productType}"/>
                    </p:column>

                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Quantity"/>
                        </f:facet>
                        <h:outputText value="#{productLine.quantity}" style="width: 150px"/>
                    </p:column>
                    
                    <p:column>
                        <f:facet name="header">
                            <h:outputText value="Final Price"/>
                        </f:facet>
                        <h:outputText value="#{productLine.finalPrice}" style="width: 150px"/>
                    </p:column>
                    
                    <f:facet name ="footer">
                        <h:outputText value="Total Price: "/>
                        <h:outputText value ="#{addShippingOrderManagerBean.selectedPackingOrder.deliveryOrder.pickingOrder.totalPrice}"/>
                    </f:facet>
                    </p:dataTable>

                <p:commandButton id="btn" value="Save New Shipping Order" update="panel" actionListener="#{addShippingOrderManagerBean.saveNewShippingOrder(event)}" ajax="false" />
                    </p:panel>
        </h:form>
      </f:view>
    </ui:define>
</ui:composition>

